package logic

import (
	"context"
	"friend/internal/svc"
	"friend/pb/friend"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateGroupRelationLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateGroupRelationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateGroupRelationLogic {
	return &UpdateGroupRelationLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// UpdateGroupRelation 好友分组关系维护
func (l *UpdateGroupRelationLogic) UpdateGroupRelation(in *friend.RelationToGroup) (*friend.Empty, error) {
	err := l.svcCtx.FriendRelationExtendModel.UpdateGroup(l.ctx, in.UserId, in.FriendId, in.GroupId, in.Status)
	if err != nil {
		return nil, err
	}
	return &friend.Empty{}, nil
}
